package com.hegongda.service.impl;

import com.hegongda.bean.User;
import com.hegongda.dao.UserDao;
import com.hegongda.service.UserService;
import com.hegongda.utils.BeanFactory;

import java.sql.SQLException;

public class UserServiceImpl implements UserService {
    private UserDao ud = BeanFactory.newInstance(UserDao.class);
    public int userRegister(User user){
        int i = -1;
        //UserDao ud = BeanFactory.newInstance(UserDao.class);
        try {
            i = ud.userRegister(user);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return i;
    }
    public User userLogin(String name,String password){
        //UserDao ud = BeanFactory.newInstance(UserDao.class);
        User user = null;
        try {
            user = ud.userLogin(name, password);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return user;
    }
    public User hasUser(String name){
        //UserDao ud = BeanFactory.newInstance(UserDao.class);
        User user = null;
        try {
            user = ud.hasUser(name);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return user;
    }
}

